<template>
    <div class="top-box">
        <titleComponent title="收入统计"></titleComponent>
        <div class="center">
            <div class="money-box" v-for="item, i in list">
                <img :src="require(`../../../assets/img/incomeIcon${i + 1}.png`)" />
                <div>
                    <div class="name">{{ item.name }}</div>
                    <div class="value" :style="{ color: item.color }">{{ item.value }}</div>
                </div>
            </div>
        </div>
    </div>
</template>
<script>
import titleComponent from "./titleComponent";
export default {
    components: {
        titleComponent,
    },
    watch: {
        income(val, oldVal) {
            if (val !== oldVal) {
                this.list = [
                    { name: "累计收入", value: val && val.totalIncome ? val.totalIncome : 0, color: '#ffab4b' },
                    { name: "IT通服收入", value: val && val.itIncome ? val.itIncome : 0, color: '#1e8aff' },
                    { name: "CT通服收入", value: val && val.ctIncome ? val.ctIncome : 0, color: '#ff293f' },
                    { name: "非通服收入", value: val && val.nIncome ? val.nIncome : 0, color: '#24e1c0' }
                ]
            }
        }
    },
    props: {
        income: {
            type: Object,
            default: () => { },
        }
    },
    data() {
        return {
            list: [
                { name: "累计收入", value: this.income && this.income.totalIncome ? this.income.totalIncome : 0, color: '#ffab4b' },
                { name: "IT通服收入", value: this.income && this.income.itIncome ? this.income.itIncome : 0, color: '#1e8aff' },
                { name: "CT通服收入", value: this.income && this.income.ctIncome ? this.income.ctIncome : 0, color: '#ff293f' },
                { name: "非通服收入", value: this.income && this.income.nIncome ? this.income.nIncome : 0, color: '#24e1c0' }
            ]
        }
    },
}
</script>
<style lang="less" scoped>
.top-box {
    background: #fff;
    width: 100%;
    height: 160px;
    margin-bottom: 16px;
    box-sizing: border-box;
    padding: 16px;
}

.center {
    display: flex;
}

.money-box {
    display: flex;
    margin-top: 30px;
    width: 25%;
    flex-wrap: wrap;

    img {
        margin-right: 20px;
        width: 52px;
        height: 52px;
    }

    .value {
        font-size: 24px;
        color: #ffab4b;
        font-weight: bold;
    }
}

.name {
    font-weight: 900;
    font-size: 16px;
}
</style>